package com.ruoyi.service.inventory.impl;

import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.domain.inventory.MesWarehouse;
import com.ruoyi.mapper.inventory.MesWarehouseMapper;
import com.ruoyi.service.inventory.IMesWarehouseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 仓库信息Service业务层处理
 * 
 * @author ruoyi
 */
@Service
public class MesWarehouseServiceImpl implements IMesWarehouseService
{
    @Autowired
    private MesWarehouseMapper mesWarehouseMapper;

    /**
     * 查询仓库信息
     * 
     * @param warehouseId 仓库信息主键
     * @return 仓库信息
     */
    @Override
    public MesWarehouse selectMesWarehouseByWarehouseId(Long warehouseId)
    {
        return mesWarehouseMapper.selectMesWarehouseByWarehouseId(warehouseId);
    }

    /**
     * 查询仓库信息列表
     * 
     * @param mesWarehouse 仓库信息
     * @return 仓库信息
     */
    @Override
    public List<MesWarehouse> selectMesWarehouseList(MesWarehouse mesWarehouse)
    {
        return mesWarehouseMapper.selectMesWarehouseList(mesWarehouse);
    }

    /**
     * 校验仓库编码是否唯一
     * 
     * @param warehouseCode 仓库编码
     * @return 结果
     */
    @Override
    public String checkWarehouseCodeUnique(String warehouseCode)
    {
        MesWarehouse warehouse = mesWarehouseMapper.checkWarehouseCodeUnique(warehouseCode);
        if (StringUtils.isNotNull(warehouse))
        {
            return "1";
        }
        return "0";
    }

    /**
     * 根据仓库类型查询仓库列表
     * 
     * @param warehouseType 仓库类型
     * @return 仓库信息集合
     */
    @Override
    public List<MesWarehouse> selectWarehousesByType(String warehouseType)
    {
        return mesWarehouseMapper.selectWarehousesByType(warehouseType);
    }

    /**
     * 查询启用状态的仓库列表
     * 
     * @return 仓库信息集合
     */
    @Override
    public List<MesWarehouse> selectActiveWarehouses()
    {
        return mesWarehouseMapper.selectActiveWarehouses();
    }

    /**
     * 新增仓库信息
     * 
     * @param mesWarehouse 仓库信息
     * @return 结果
     */
    @Override
    public int insertMesWarehouse(MesWarehouse mesWarehouse)
    {
        return mesWarehouseMapper.insertMesWarehouse(mesWarehouse);
    }

    /**
     * 修改仓库信息
     * 
     * @param mesWarehouse 仓库信息
     * @return 结果
     */
    @Override
    public int updateMesWarehouse(MesWarehouse mesWarehouse)
    {
        return mesWarehouseMapper.updateMesWarehouse(mesWarehouse);
    }

    /**
     * 批量删除仓库信息
     * 
     * @param warehouseIds 需要删除的数据主键集合
     * @return 结果
     */
    @Override
    public int deleteMesWarehouseByWarehouseIds(Long[] warehouseIds)
    {
        return mesWarehouseMapper.deleteMesWarehouseByWarehouseIds(warehouseIds);
    }

    /**
     * 删除仓库信息信息
     * 
     * @param warehouseId 仓库信息主键
     * @return 结果
     */
    @Override
    public int deleteMesWarehouseByWarehouseId(Long warehouseId)
    {
        return mesWarehouseMapper.deleteMesWarehouseByWarehouseId(warehouseId);
    }
}